package cn.cdeden.knowledge.dubbo;

import cn.cdeden.knowledge.api.domain.RemoteFileService;
import cn.cdeden.knowledge.api.domain.vo.RemotePersonalTreeVo;
import cn.cdeden.knowledge.domain.PersonalFilesTree;
import cn.cdeden.knowledge.service.FileService;
import io.undertow.util.BadRequestException;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor
@Service
@DubboService
public class RemoteFileServiceImpl implements RemoteFileService {

    private final FileService fileService;


    @Override
    public boolean upDateFolderSizeUpDate(String userId, RemotePersonalTreeVo filesTree, Long originalSize, Long newSize, String type) {
        PersonalFilesTree personalFilesTree = new PersonalFilesTree();
        personalFilesTree.setId(filesTree.getId());
        personalFilesTree.setSort(filesTree.getSort());
        personalFilesTree.setTopParentId(filesTree.getTopParentId());
        personalFilesTree.setParentId(filesTree.getParentId());
        personalFilesTree.setSuperiorsIds(filesTree.getSuperiorsIds());
        personalFilesTree.setSuffix(filesTree.getSuffix());
        personalFilesTree.setRealName(filesTree.getRealName());
        personalFilesTree.setSuperiorsPath(filesTree.getSuperiorsPath());
        personalFilesTree.setPath(filesTree.getPath());
        personalFilesTree.setType(filesTree.getType());
        personalFilesTree.setStorageId(filesTree.getStorageId());
        personalFilesTree.setStorageType(filesTree.getStorageType());
        personalFilesTree.setSize(filesTree.getSize());
        personalFilesTree.setEditionName(filesTree.getEditionName());
        personalFilesTree.setEdition(filesTree.getEdition());
        personalFilesTree.setFileMd5(filesTree.getFileMd5());
        personalFilesTree.setLinkingState(filesTree.getLinkingState());
        personalFilesTree.setCreateId(filesTree.getCreateId());
        personalFilesTree.setCreateBy(filesTree.getCreateBy());
        personalFilesTree.setCreateTime(filesTree.getCreateTime());
        personalFilesTree.setUpdateId(filesTree.getUpdateId());
        personalFilesTree.setUpdateBy(filesTree.getUpdateBy());
        personalFilesTree.setUpdateTime(filesTree.getUpdateTime());
        personalFilesTree.setDeleteId(filesTree.getDeleteId());
        personalFilesTree.setDeleteBy(filesTree.getDeleteBy());
        personalFilesTree.setDeleteTime(filesTree.getDeleteTime());
        personalFilesTree.setDeleteType(filesTree.getDeleteType());
        personalFilesTree.setRemarks(filesTree.getRemarks());
        personalFilesTree.setSys(filesTree.getSys());
        personalFilesTree.setDocContent(filesTree.getDocContent());
        personalFilesTree.setCollection(filesTree.getCollection());
        return fileService.upDateFolderSizeUpDate(userId, personalFilesTree, originalSize, newSize, type);
    }
}
